package com.zut.dao.impl;

import com.zut.dao.CategoryDao;
import com.zut.pojo.Category;
import com.zut.utils.DruidUtil;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * @author 张晨
 * @date 2024/9/12 10:33
 * @desc
 */
public class CategoryDaoImpl implements CategoryDao {
    private JdbcTemplate jdbcTemplate = new JdbcTemplate(DruidUtil.getDataSource());
    @Override
    public List<Category> selectAll() {
        String sql = "select * from shop_category";

        return jdbcTemplate.query(sql,new BeanPropertyRowMapper<Category>(Category.class));

    }

    @Override
    public Integer deleteById(int i) {
        String sql = "delete from shop_category where shop_category_id = ?";
        return jdbcTemplate.update(sql,i);
    }
}
